package cn.wen.forum.mapper;

import cn.wen.forum.pojo.entity.Review;
import cn.wen.forum.vo.ReviewVO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface ReviewMapper extends BaseMapper<Review> {

    /**
     * 根据id查询评论list集合以及相关用户信息 （id，头像,等级）
     * @param id
     * @return
     */
    @Select("select T1.head_portrait,T1.level,T1.empirical_value,T1.admini_strator, T2.* " +
            "from tb_review T2 join tb_user T1 " +
            "on T2.post_id = #{id} and T1.id = T2.user_id order by time desc"
    )
    List<ReviewVO> selectReviewAndUserHead(String id);
}
